﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using ChatDAL;

namespace ChatService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IServiceChat" in both code and config file together.
    [ServiceContract]
    public interface IServiceChat
    {
        [OperationContract]
        [WebGet(UriTemplate = "ListChannels")]
        List<ChannelDTO> ListChannels();

        [OperationContract]
        [WebInvoke(Method = "POST",
           BodyStyle = WebMessageBodyStyle.Bare,
           RequestFormat = WebMessageFormat.Json,
           UriTemplate = "ShowMessages")]
        MessageDTO[] ShowMessages(MessagesContactor contactor);

        [OperationContract]
        [WebInvoke(Method = "POST",
           BodyStyle = WebMessageBodyStyle.Bare,
           RequestFormat = WebMessageFormat.Json,
           UriTemplate = "PostMessage")]
        void PostMessage(MessageDTO message);

        [OperationContract]
        [WebInvoke(Method = "POST",
           BodyStyle = WebMessageBodyStyle.Bare,
           RequestFormat = WebMessageFormat.Json,
           UriTemplate = "ResetChannel")]
        void ResetChannel(ChannelDTO channel);

    }

    [DataContract]
    public class MessagesContactor
    {
        [DataMember]
        public string Channel { get; set; }
        [DataMember]
        public int NumberOfMessagesToBeShown { get; set; }
    }
}
